<?

function sortAndSplit(&$var1,&$var2,&$var3) {
	if($var1>$var2) {
		$split="var1";
	} else {
		$split="var2";
	}
	if($$split<$var3) {
		$split="var3";
	}
	$stack=$$split;
	$$split=0;
	while($stack>0) {
		$addingto="var" . (($stack%3)+1);
		$$addingto++;
		$stack--;
	}
}
$one=rand(60,200);
$two=0;
$three=0;
for($i=0;$i<20;$i++) {
echo "<br>Attempt Number " . $i . "<br>
Stack1: " . $one . ", Stack2: " . $two. ", Stack3: " . $three;
sortAndSplit($one,$two,$three);
}